package com.glory.hikvisionmobile.adapter;

import android.graphics.Color;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.hikvisionmobile.R;
import com.glory.hikvisionmobile.base.App;
import com.glory.hikvisionmobile.bean.EqpManger.EqpCheckListBean;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DateUtils;

import java.util.List;

public class EqpCheckListAdapter extends BaseQuickAdapter<EqpCheckListBean, BaseViewHolder> {

    private boolean isEqpCheck;

    public EqpCheckListAdapter(@Nullable List<EqpCheckListBean> data,boolean isEqpCheck) {
        super(R.layout.adapter_param_list,data);
        this.isEqpCheck = isEqpCheck;
    }

    @Override
    protected void convert(BaseViewHolder helper, EqpCheckListBean item) {
        helper.setText(R.id.tvItem1,String.valueOf((helper.getAdapterPosition() + 1)));
        helper.setText(R.id.tvItem2,item.getSheetName());
        if (isEqpCheck){
            helper.setText(R.id.tvItem4,item.getEqpId());
            helper.setText(R.id.tvItem5,getStatus(item.getStatus()));
            helper.setText(R.id.tvItem3, item.getFromTime());

        }else {
            helper.setText(R.id.tvItem3, item.getSheetDesc());
            helper.setText(R.id.tvItem4,item.getFromTime());
            helper.setText(R.id.tvItem5,getStatus(item.getStatus()));
        }

        switch (item.getStatus()){
            case "CREATE"://创建
                helper.setTextColor(R.id.tvItem1, App.app.getResources().getColor(R.color.blue));
                helper.setTextColor(R.id.tvItem2, App.app.getResources().getColor(R.color.blue));
                helper.setTextColor(R.id.tvItem3, App.app.getResources().getColor(R.color.blue));
                helper.setTextColor(R.id.tvItem4, App.app.getResources().getColor(R.color.blue));
                helper.setTextColor(R.id.tvItem5, App.app.getResources().getColor(R.color.blue));
                break;
            case "START"://已开始
                helper.setText(R.id.tvItem3,"开始");
                helper.setTextColor(R.id.tvItem1, App.app.getResources().getColor(R.color.green));
                helper.setTextColor(R.id.tvItem2, App.app.getResources().getColor(R.color.green));
                helper.setTextColor(R.id.tvItem3, App.app.getResources().getColor(R.color.green));
                helper.setTextColor(R.id.tvItem4, App.app.getResources().getColor(R.color.green));
                helper.setTextColor(R.id.tvItem5, App.app.getResources().getColor(R.color.green));
                break;
            case "CANSTART"://可以开始
                helper.setText(R.id.tvItem3,"可以开始");
                helper.setTextColor(R.id.tvItem1, App.app.getResources().getColor(R.color.free_ui_deep_green));
                helper.setTextColor(R.id.tvItem2, App.app.getResources().getColor(R.color.free_ui_deep_green));
                helper.setTextColor(R.id.tvItem3, App.app.getResources().getColor(R.color.free_ui_deep_green));
                helper.setTextColor(R.id.tvItem4, App.app.getResources().getColor(R.color.free_ui_deep_green));
                helper.setTextColor(R.id.tvItem5, App.app.getResources().getColor(R.color.free_ui_deep_green));
                break;
            case "FORM"://已临时保存
                helper.setText(R.id.tvItem3,"临时保存");
                helper.setTextColor(R.id.tvItem1, App.app.getResources().getColor(R.color.orange));
                helper.setTextColor(R.id.tvItem2, App.app.getResources().getColor(R.color.orange));
                helper.setTextColor(R.id.tvItem3, App.app.getResources().getColor(R.color.orange));
                helper.setTextColor(R.id.tvItem4, App.app.getResources().getColor(R.color.orange));
                helper.setTextColor(R.id.tvItem5, App.app.getResources().getColor(R.color.orange));
                break;
            case "COMPLETE"://已完成
                helper.setText(R.id.tvItem3,"已完成");
                helper.setTextColor(R.id.tvItem1, App.app.getResources().getColor(R.color.free_ui_yellow_theme_color));
                helper.setTextColor(R.id.tvItem2, App.app.getResources().getColor(R.color.free_ui_yellow_theme_color));
                helper.setTextColor(R.id.tvItem3, App.app.getResources().getColor(R.color.free_ui_yellow_theme_color));
                helper.setTextColor(R.id.tvItem4, App.app.getResources().getColor(R.color.free_ui_yellow_theme_color));
                helper.setTextColor(R.id.tvItem5, App.app.getResources().getColor(R.color.free_ui_yellow_theme_color));
                break;
            case "WARNING"://警告
                helper.setText(R.id.tvItem3,"警告");
                helper.setTextColor(R.id.tvItem1, Color.argb(255,255,182,193));
                helper.setTextColor(R.id.tvItem2, Color.argb(255,255,182,193));
                helper.setTextColor(R.id.tvItem3, Color.argb(255,255,182,193));
                helper.setTextColor(R.id.tvItem4, Color.argb(255,255,182,193));
                helper.setTextColor(R.id.tvItem5, Color.argb(255,255,182,193));
                break;
            default:
                helper.setTextColor(R.id.tvItem1, App.app.getResources().getColor(R.color.red));
                helper.setTextColor(R.id.tvItem2, App.app.getResources().getColor(R.color.red));
                helper.setTextColor(R.id.tvItem3, App.app.getResources().getColor(R.color.red));
                helper.setTextColor(R.id.tvItem4, App.app.getResources().getColor(R.color.red));
                helper.setTextColor(R.id.tvItem5, App.app.getResources().getColor(R.color.red));
                break;
        }


    }

    private String getStatus(String status) {
        String str = "";
        switch (status){
            case "CREATE":
                str = "创建";
                break;
            case "WARNING":
                str = "警告";
                break;
            case "CANSTART":
                str = "可以开始";
                break;
            case "START":
                str = "开始";
                break;
            case "FORM":
                str = "临时保存";
                break;
            case "COMPLETE":
                str = "已完成";
                break;
            case "TIMEOUT":
                str = "超时";
                break;
            default:
                break;

        }
        return str;
    }


}
